package com.mnt.washio.activities;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.WindowManager;

import com.mnt.washio.R;
import com.mnt.washio.adapters.ImageAdapter;
import com.viewpagerindicator.CirclePageIndicator;
import com.viewpagerindicator.PageIndicator;

public class WalkThroughActivity extends FragmentActivity {
	private ImageAdapter mAdapter;
	private ViewPager mPager;
	private PageIndicator mIndicator;
	private SharedPreferences pref;
	private Editor edt;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_walkthrough);

		overridePendingTransition(R.anim.slide_in_from_right, R.anim.anim_alpha);

		init();
	}

	private void init() {
		pref = getSharedPreferences("MNT_WASHIO", MODE_PRIVATE);
		edt = pref.edit();
		
		getWindow().setSoftInputMode(
				WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

		mPager = (ViewPager) findViewById(R.id.pager);

		mAdapter = new ImageAdapter(this, getResources().getStringArray(
				R.array.walk_through));
		mPager.setAdapter(mAdapter);

		mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
		mIndicator.setViewPager(mPager);
	}

	public void onGetStarted(View v) {
		if (getIntent().getBooleanExtra("FROM_SPLASH", false)) {
			startActivity(new Intent(this, LoginActivity.class));
		}
		

		pref = getSharedPreferences("MNT_WASHIO", MODE_PRIVATE);
		edt = pref.edit();
		edt.putBoolean("FIRST_LAUNCH", false);
		edt.commit();
		
		finish();
	}

	@Override
	public void onBackPressed() {
		// do no thing
	}
}
